<script type="text/javascript" src="./jscript/jquery.yiigridview.js"></script>
<script type="text/javascript" src="./jscript/flexigrid.min.js"></script>

<script>


console.log('$.fn.yiiGridView:');
console.log($.fn.yiiGridView());


$(function(){
  var size = $('#multiformstep > .formstep').size();
	var currentstep = 1;
	// console.log(size);
	
	$('#nextstep').bind('click', function(){
	
	});
});	


;(function($){
  /*alert($); alert打印如下内容	
  function (selector, context) {
    return new jQuery.fn.init(selector, context, rootjQuery);
  }	
	*/
	$.fn.formWizard = function(options){
		var options = $.extend({}, $.fn.formWizard.defaults, options);		
    var args = arguments;
		var action = $(this).attr('action');
		stepDiv = $(this).children('.step');
		var stepSize = stepDiv.size();
    return this.each(function() {     
      $this = $(this);
			$('#nextstep').bind('click', function(){
			  step();
				if (stepnum+1 >= stepSize) {
				  return false;// 最后一步
				}
				
				var content = $.ajax({
				  url:action+'&step='+stepnum,
					// data:'',
					type:'POST',
					dataType:'json',
					success:successRequest,
					error:errorRequest
				}).responeText;
				// alert(content);
				  stepDiv.slideUp();
				  stepDiv.eq(stepnum+1).slideDown();
			  });
			
		  $('#prestep').bind('click', function(){
			  step();
				if (stepnum<=0) {
				  return false;// 第一步
				}
				stepDiv.eq(stepnum - 1).slideDown();
			  stepDiv.eq(stepnum).slideUp();
			});
			function step(){
			   // alert('step()');
			   stepDiv.each(function(k, v){
				   if ($(this).css('display')=='block') stepnum = k;
			   });
			}
			
			function errorRequest(data){
			   //console.log('errorRequest');
				 //console.log(data);
			}
			
			function successRequest(data){
			   // alert('successRequest:'+data);
				 // console.log('successRequest');
				 // console.log(data);
			  //alert('successRequest');
			}
    });
	};
	
		
	
})(jQuery);

  $.fn.formJscript = function(options1, options2){
			// p = $.extend(true, $.fn.yiiGridView, options1 );
			
			var methods = {
			   fun1:function(){
			    // console.log('formJscript.fun1');
					//console.log(p.option1);
			  },
				
				fun2: function(){
				  $.extend(true, $.fn.yiiGridView, options1 );
				}
			};
			
			// fun1();
			// console.log(p);
			// return p;
	}

//console.log($.fn.formJscript.methods.fun2());
$(function(){

	
	var sc = new $.fn.formJscript({'option1':'o1'}, {'option2':'o2'});
	// sc.fun1();
	// $.formJscript.fun1();
	
	// sc = new $.fn.formJscript({'aa':'bb'});
	// console.log(sc.step());
	//sc.step();
	$('#formWizard').formWizard();
});	
</script>
<style>
.disn{
   display:none;
}
</style>
<form action="<?php echo Yii::app()->createUrl('formstep/create');?>" name="SignupForm" id="formWizard">
    <div class="step">
        <div class="formstep">111</div>
        <div class="stepnum">111</div>
        <div class="stepnum">111</div>
        <div class="stepnum">111</div>
        <div class="stepnum">111</div>
    </div>
		
    <div class="step disn">
        <div class="formstep">222</div>
        <div class="stepnum">222</div>
        <div class="stepnum">222</div>
        <div class="stepnum">222</div>
        <div class="stepnum">222</div>
    </div>
		
    <div class="step disn">
        <div class="stepnum">333</div>
        <div class="stepnum">333</div>
        <div class="stepnum">333</div>
        <div class="stepnum">333</div>
        <div class="stepnum">333</div>
    </div>
		
    <div class="step disn">
        <div class="stepnum">4444</div>
        <div class="stepnum">4444</div>
        <div class="stepnum">4444</div>
        <div class="stepnum">4444</div>
        <div class="stepnum">4444</div>
    </div>
		<div class="submit" style="cursor:pointer"><span id='prestep'>上一步</span><span id="nextstep">下一步</span><span id='finish'>完成</span></div>						
</form>
